<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>demo - div</div>
    <div>demo - div</div>
    <div>demo - div</div>
    <div>demo - div</div>
    <div>demo - div</div>
    <script>
        (function(window, undefined) {
            var jQuery = function(selector) {
                return new jQuery.fn.init(selector);
            }

            // 原型替换
            jQuery.fn = jQuery.prototype = {
                constructor: jQuery,
                init: function(selector) {

                    var elements = document.querySelectorAll(selector);

                    [].push.apply(this, elements);
                },
                css: function(name, value) {
                    if (arguments.length === 2) {
                        // console.log(name, value);
                        for (var i = 0; i < this.length; i++) {

                            // this[i].style.name = value; // 没有效果
                            this[i].style[name] = value;
                        }
                    }
                }
            }
            jQuery.fn.init.prototype = jQuery.fn;

            // 暴露
            window.jQuery = window.$ = jQuery;
        })(window)

        var $divs = $("div");

        $divs.css("color", "lime");
        $divs.css("fontSize", "50px");
    </script>
</body>

</html>